/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package servlet;

import dao.BookDao;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/mbs")
public class ModifyBookServlet extends HttpServlet{

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        int bookId=Integer.parseInt(req.getParameter("bookid"));
        String bookName=req.getParameter("bookname");
        String author=req.getParameter("author");
        String publishDate=req.getParameter("publishdate");
        String publishHouse=req.getParameter("publishhouse");
        String type=req.getParameter("type");
        String introduction=req.getParameter("introduction");
        int mark=Integer.parseInt(req.getParameter("mark"));
        float price=Float.parseFloat(req.getParameter("price"));
        
        Boolean bool=new BookDao().modifyBook(bookId,bookName,author,publishDate,publishHouse,type,introduction,mark,price);
        resp.setContentType("text/html;charset=utf-8");
        if(bool==false){
            resp.getWriter().println("<script language='javascript'>alert('修改失败！');window.location.href='Admin.jsp';</script>");
        }
        else{
            resp.getWriter().println("<script language='javascript'>alert('图书修改成功！');window.location.href='Admin.jsp';</script>");
        }
        resp.getWriter().println("<a href='Admin.jsp'>返回</a>");
    }
    
    
}
